package com.effectiv.panchoo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.hazelcast.config.Config;
import com.hazelcast.config.GroupConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IList;

@Configuration
public class HazelcastConfig {
	
	//TODO Remove later for room category
	String rooms [] = {"Kolkata", "Mumbai","Chennai","Delhi", "Bengaluru","Hyderabad"};
	
	@Bean(name="HazelCastServer")
	public HazelcastInstance createHazelcast(){
		GroupConfig gc = new GroupConfig();
		gc.setName("dev");
		gc.setPassword("dev");
		
		Config config = new Config();
		
		HazelcastInstance hc = Hazelcast.newHazelcastInstance(config);
		
		IList<String> roomList = hc.getList("rooms");
		
		for(String r : rooms) {
			roomList.add(r);
		}
		
		return hc;
	}
}
